/*    */ package system.staros.sblock1;
/*    */ 
/*    */ import java.util.ArrayList;
/*    */ import java.util.List;
/*    */ 
/*    */ public class FunctionNode extends Node
/*    */ {
/* 35 */   public static final List<Node> NO_PARAMETERS = new ArrayList(0);
/*    */   private List<Node> parameters;
/*    */   private Node body;
/*    */ 
/*    */   public FunctionNode(SourcePosition paramSourcePosition, List<Node> paramList, Node paramNode)
/*    */   {
/* 41 */     super(paramSourcePosition);
/* 42 */     this.parameters = paramList;
/* 43 */     this.body = paramNode;
/*    */   }
/*    */ 
/*    */   public ZemObject eval(Interpreter paramInterpreter)
/*    */   {
/* 48 */     ArrayList localArrayList = new ArrayList(this.parameters.size());
/* 49 */     for (Node localNode : this.parameters)
/*    */     {
/*    */       String str;
/*    */       ZemObject localZemObject;
/* 53 */       if ((localNode instanceof VariableNode)) {
/* 54 */         str = ((VariableNode)localNode).getName();
/* 55 */         localZemObject = null;
/* 56 */       } else if ((localNode instanceof AssignNode)) {
/* 57 */         str = ((VariableNode)((AssignNode)localNode).getLeft()).getName();
/* 58 */         localZemObject = ((AssignNode)localNode).getRight().eval(paramInterpreter);
/*    */       }
/*    */       else {
/* 61 */         throw new RuntimeException("Invalid function");
/*    */       }
/* 63 */       Parameter localParameter = new Parameter(str, localZemObject);
/* 64 */       localArrayList.add(localParameter);
/*    */     }
/* 66 */     return new UserFunction(localArrayList, this.body);
/*    */   }
/*    */ 
/*    */   public String toString()
/*    */   {
/* 71 */     StringBuilder localStringBuilder = new StringBuilder();
/* 72 */     localStringBuilder.append("(function (");
/* 73 */     int i = 1;
/* 74 */     for (Node localNode : this.parameters) {
/* 75 */       if (i != 0)
/* 76 */         i = 0;
/*    */       else {
/* 78 */         localStringBuilder.append(' ');
/*    */       }
/* 80 */       localStringBuilder.append(localNode);
/*    */     }
/* 82 */     localStringBuilder.append(") ");
/* 83 */     localStringBuilder.append(this.body);
/* 84 */     localStringBuilder.append(')');
/* 85 */     return localStringBuilder.toString();
/*    */   }
/*    */ }

/* Location:           D:\Марк\!IMPORTANT\staros\archive\version-2.260.zip
 * Qualified Name:     system.staros.sblock1.FunctionNode
 * JD-Core Version:    0.6.1
 */